fix: resolve failing tests and type errors across api and shared packages#61
Open
stooit wants to merge 1 commit into
Open
fix: resolve failing tests and type errors across api and shared packages#61stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
…ages - auth middleware: include POST in public methods (HTTP methods are uppercase) and read token via Bun.env to satisfy tsc - shared types: rename User.userName -> username to match the contract used by db, routes, and tests - users route: import missing badRequest helper from lib/errors - shared: implement paginate() stub with correct slicing, total, totalPages, and out-of-range/empty edge cases - tsconfig: ensure bun/process types resolve without new deps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes all failing tests and eliminates all
tsc --noEmittype errors in the Bun + Hono TypeScript monorepo. Final state: 22 tests pass, 0 fail;bunx tsc --noEmitclean.Bugs spanned both the
apiandsharedpackages.Fixes
packages/api/src/middleware/auth.ts) — case-sensitivity bug:POSTwas listed in lowercase in the public-methods check, but Hono'sc.req.methodis always uppercase (RFC 7231), soPOST /usersincorrectly required a token. AddedPOSTto the uppercase public-methods list. Also switched the token lookup toBun.envso it type-checks without@types/node.packages/shared/src/types.ts) —User.userNamerenamed tousernameto match the field name already used bydb.ts, the users route, and the test suite. The type was the outlier; aligned it to the actual contract.packages/api/src/routes/users.ts) — added the missingbadRequestimport from../lib/errors, fixing a runtime failure on the 400 validation path.packages/shared/src/utils/pagination.ts) — implemented thepaginate()stub: page slicing,total,totalPages(Math.ceil), correctpage/pageSizefields, and edge cases for empty input and out-of-range pages (returns empty data).tsconfig.json— ensured Bun/process types resolve without adding any dependency.Verification
bun test-> 22 pass / 0 failbunx tsc --noEmit-> clean (exit 0)Assumptions
username(lowercase), per the tests and existingdb/route code.Bun.env/process.envequivalence in the Bun runtime is relied upon so the fix needs no@types/nodedependency.